/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.upn.sigemfi.seg.be;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Programador
 */
@Entity
@Table(name = "SEG_EMPLEADO", uniqueConstraints = {@UniqueConstraint(columnNames = {"FID_SEG_USUARIO"})})
@NamedQueries({@NamedQuery(name = "Empleado.findAll", query = "SELECT e FROM Empleado e"), @NamedQuery(name = "Empleado.findByIdEmpleado", query = "SELECT e FROM Empleado e WHERE e.idEmpleado = :idEmpleado")})
@PrimaryKeyJoinColumn(name = "ID_EMPLEADO", referencedColumnName = "ID_PERSONA")
@DiscriminatorValue("EMP")
public class Empleado
        extends Persona
        implements Serializable {

    @JoinColumn(name = "FID_SEG_CARGO", referencedColumnName = "ID_CARGO")
    @ManyToOne(fetch = FetchType.LAZY)
    private Cargo fidSegCargo;
    @JoinColumn(name = "FID_SEG_USUARIO", referencedColumnName = "ID_USUARIO", nullable = false)
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Usuario fidSegUsuario;

    public Empleado() {
    }

    public Cargo getFidSegCargo() {
        return fidSegCargo;
    }

    public void setFidSegCargo(Cargo fidSegCargo) {
        this.fidSegCargo = fidSegCargo;
    }

    public Usuario getFidSegUsuario() {
        return fidSegUsuario;
    }

    public void setFidSegUsuario(Usuario fidSegUsuario) {
        this.fidSegUsuario = fidSegUsuario;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPersona != null ? idPersona.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Persona)) {
            return false;
        }
        Persona other = (Persona) object;
        if ((this.idPersona == null && other.idPersona != null) || (this.idPersona != null && !this.idPersona.equals(other.idPersona))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "edu.upn.sigemfi.seg.be.Persona[idPersona=" + idPersona + "]";
    }
}
